Day 2 - Printing

Solutions to exercises

Exercise 2.01

Print the string “Just a test”

Solution

$ echo "Just a test"

Just a test

As we discussed in the chapter this can also be solved running

$ echo Just a test

Just a test

but I believe the first solution is better. It is immediately clear which part of the command is the

string and later, when we will create scripts in an editor, strings between quotes are highlighted.

Go back to the exercise

Exercise 2.02

Print a string without the trailing newline (check the manual page)

Solution

Open the man page for echo and search for the pattern trailing newline. You should find that

-n

do not output the trailing newline

So, if you run